package jsc.acid;

/**
 * a word is a piece of a instance of Text, it's not very different from a simple String but it hold a boolean marker wich
 * indicates if the word has already been checked for its existence in a dictionary (or list of)
 * 
 * @author Alec Ermis, Maxime Rihouey
 *
 */
public class Word {

	private String word;
	private int startIndex; // the index of start in the text, can be set to -1 if not useful
	private boolean checked;

	// constructors
	public Word(String word, int startIndex){
		this.word = word;
		checked = false;
		this.startIndex = startIndex;
	}

	public Word(String word){
		this(word,-1);
	}

	// getters
	public String getWord(){
		return word;
	}

	public boolean isChecked(){
		return checked;
	}

	public int getStartIndex(){
		return startIndex;
	}

	// setters
	public void markAsChecked(){
		checked = true;
	}

	// display
	public String toString(){
		return word;
	}

	/*
	 * Test
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		System.out.println("###################### Test Positif ################");

		// test positif
		Word word = new Word("mot", 0);
		System.out.println(word.getWord());
		System.out.println(word.isChecked());
		word.markAsChecked();
		System.out.println(word.isChecked());


		System.out.println("###################### Test Negatif ################");

		// test negatif
		word = new Word("", -1);
		System.out.println(word.getStartIndex());
		System.out.println(word.getWord());
	}
}
